package com.sgzn.sgpay.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 设备类型
 * @author zhongzhongyong
 * @version Id: DeviceType.java, v 0.1 2018/5/17 11:48 zhongzhongyong Exp $$
 */
public enum DeviceType {
    WWJ("01", "娃娃机"),
    DBJ("02", "兑币机");

    @Getter
    private String code;
    @Getter
    private String desc;

    //构造函数
    DeviceType(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private static final Map<String, String> map = new HashMap<String, String>();

    static{
        for(DeviceType single : DeviceType.values()){
            map.put(single.code, single.desc);
        }
    }

    /**
     * 根据编码码获取类型
     * @param code
     * @return
     */
    public static String getDescByCode(String code) {
        if(isContain(code)){
            return map.get(code);
        }
        return code+"未定义";
    }

    public static boolean isContain(String code){
        if(map.containsKey(code)){
            return true;
        }
        return false;
    }

}
